package cn.gok;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Date类 {
    public static void main(String[] args) throws ParseException {
        Date类的常用方法();
    }

    private static void Date类的常用方法() throws ParseException {
        Date date=new Date();
        System.out.println(date);
        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //SimpleDateFormat sdf =new SimpleDateFormat("yyyy年MM月dd日 hh时mm分ss秒");
        System.out.println(sdf.format(date));
        String time="2000-11-02 12:00:00";
        Date date2=sdf.parse(time);
        System.out.println(date2);
        //
        System.out.println("距1970-1-1 0时的毫秒数："+date.getTime());
        long now=date.getTime();
        long then=date2.getTime();
        long days=(now-then)/1000/(3600*24);
        System.out.println("距离的天数:"+days);
    }
}
